/*
 * $Id: $
 */
package org.rcgwt.client.ui.grid.internal;

import org.rcgwt.client.ui.grid.internal.model.IColumnModel;
import org.rcgwt.client.ui.grid.internal.model.IColumnModel.OrderingMark;

/**
 * 
 * @author Olivier Oeuillot (latest modification by $Author: $)
 * @version $Revision: $ $Date: $
 */
public class ColumnModelDelta extends DefaultModelElementDelta<IColumnModel> {

    private static final int ORDERING_MASK_CHANGED = 0x100;

    private OrderingMark oldOrderingMask;

    private OrderingMark newOrderingMask;

    protected ColumnModelDelta(IColumnModel elementModel) {
        super(elementModel);
    }

    public void performOrderingMaskChanged(OrderingMark oldOrderingMask,
            OrderingMark newOrderingMark) {

        if (hasOrderingMaskChanged()) {
            this.newOrderingMask = newOrderingMark;
            return;
        }

        updateKind(ORDERING_MASK_CHANGED);

        this.oldOrderingMask = oldOrderingMask;
        this.newOrderingMask = newOrderingMark;
    }

    public boolean hasOrderingMaskChanged() {
        return (getKind() & ORDERING_MASK_CHANGED) > 0;
    }

    public OrderingMark getOldOrderingMask() {
        return oldOrderingMask;
    }

    public OrderingMark getNewOrderingMask() {
        return newOrderingMask;
    }

}
